<template>
  <view class="page-body">
	  <u-navbar :is-back="false" title="订单列表"
	    title-size="30"
	    :background="{background:'#2B88FE' }"
	    title-color="#fff">
	    <div class="head_icon">
	      <u-icon @click="$api.handleBackTo"
	        name="arrow-left" color="#fff"
	        size="36">
	      </u-icon>
	      <u-icon @click="$api.handleHomeTo"
	        name="home" color="#fff" size="36">
	      </u-icon>
	    </div>
	  </u-navbar>
	  
    <u-tabs :list="list" class="" :is-scroll="false" active-color="#1677FF" inactive-color="#666666"
      :current="info.value.OrderStatus" @change="change">
    </u-tabs>
    <view class="u-skeleton" style="height: 16rpx;">
    </view>
    <u-empty text="暂无数据" mode="list" v-if="!clist.length">
    </u-empty>
    <view class="u-skeleton-fillet" @click="toDetail(li)" v-for="(li,index) in clist" :key="index">
      <orlist class="" :item='li'>
        <view slot="right">
          
          <view :class="li.fStatus==10?'yi':'wei'">
            {{$api.getOrderStatus(li.fStatus)}}
          </view>

        </view>
	
		
        <u-button
          @click="$api.navigator(`/pages/sale/order_detail?id=${li.fId}&taskId=${li.fTaskId}&status=order`)"
          slot="button" type="primary" size="medium"> 查看详情 </u-button>
      </orlist>
	  
	  <view class="slot-content">
	    <u-table>
	      <u-tr class="u-tr">
	        <u-th class="u-th" width="30%">商品名称</u-th>
	        <u-th class="u-th" width="15%">单位</u-th>
	        <u-th class="u-th" width="15%">数量</u-th>
	        <u-th class="u-th">单价</u-th>
	        <u-th class="u-th">金额</u-th>
	      </u-tr>
	      <u-tr class="u-tr" v-for="(item,i) in li.OrderProList" :key="i">
	        <u-td class="u-td" width="30%">{{item.fProName}}</u-td>
	        <u-td class="u-td" width="15%">{{item.fUnit}}</u-td>
	        <u-td class="u-td" width="15%">{{item.fCount}}</u-td>
	        <u-td class="u-td">{{item.fPrice}}</u-td>
	        <u-td class="u-td">{{item.fMoney}}</u-td>
	      </u-tr>
	    </u-table>
	  </view>
    </view>
  </view>
</template>

<script>
import { orderStatus } from '@/util/setting'
import orlist from '../../components/orlist'
export default {
  components: {
    orlist
  },
  onShareAppMessage() {},
  data() {
    return {
      list: Object.values(orderStatus).map(x => ({ name: x })),
      current: 0,
      clist: [],
      isAllList: 1,
      page: 1,
      status: 'loading',
      loading: true,
      keywords: '',
      info: {
        PageSize: 10,
        PageIndex: 1,
        value: {
          MrkId: 0,
          OrderStatus: 0,
          OrderType: 1,
          Key: ''
        }
      }
    }
  },
  onReachBottom() {
    if (this.isAllList != 0) {
      this.info.PageIndex += 1
      this.getList()
    }
  },
  onShow() {
    const switchId = uni.getStorageSync('switchId')
    if (switchId) {
      this.info.value.OrderStatus = Number(switchId)
    }
    uni.setNavigationBarTitle({
      title: '我的订单'
    })
    this.defaultData()
    this.getList()
  },
  methods: {
    toDetail(e) {
      this.$api.navigator('order_detail?orderid=' + e.id)
    },
    change(e) {
      this.info.value.OrderStatus = e
      this.defaultData()
      this.getList()
    },
    defaultData() {
      this.clist = []
      this.isAllList = 1
      this.info.PageIndex = 1
      this.status = 'loading'
      this.loading = true
    },
    getList() {
      let that = this
      this.$axios('api/OrderBasic/ListUserPaged', 'post', this.info).then(res => {
        if (!res.Value.List.length) this.isAllList = 0
        res.Value.List.forEach(x => {
          x.img = this.urlimg + x.fPic
          x.id = x.fMrkId
          x.name = x.fMrkName
        })
        that.loading = false
        that.clist.push(...res.Value.List)
      })
    }
  }
}
</script>

<style lang="scss">
.clist {
  margin-bottom: 16rpx;
  background-color: #ffffff;

  .top {
    padding: 34rpx 32rpx;
    box-sizing: border-box;

    .code {
      font-size: 32rpx;
      font-weight: 500;
      color: #34404a;
    }

    .state {
      font-size: 30rpx;
      font-weight: 400;
      color: #2b88fe;
    }
  }

  .info {
    padding: 32rpx 32rpx 16rpx 32rpx;
    box-sizing: border-box;

    .itxt {
      padding-bottom: 16rpx;
      font-size: 28rpx;
      font-weight: 400;
      color: #34404a;
      line-height: 40rpx;
    }

    .photoShowIcon {
      width: 64rpx;
      height: 64rpx;
    }
  }

  .store {
    padding: 24rpx 32rpx;
    box-sizing: border-box;

    .simg {
      width: 56rpx;
      height: 56rpx;
      margin-right: 24rpx;
      background-color: #f2f2f2;
      border-radius: 10rpx;
    }

    .sname {
      font-size: 28rpx;
      font-weight: 500;
      color: #333333;
      line-height: 36rpx;
      padding: 0 20rpx 0 0;
    }

    .pay {
      width: 144rpx;
      height: 64rpx;
      line-height: 64rpx;
      text-align: center;
      font-size: 28rpx;
      font-weight: 400;
      color: #1677ff;
      border-radius: 32rpx;
      border: 1rpx solid #2b88fe;
    }
  }
}

page {
  background: #f8f9fc;
}
</style>
